Do not skip the root path if it's a dotdir
authorPhilipp Gesang <phg@phi-gamma.net>
Fri, 2 Oct 2015 20:27:41 +0000 (22:27 +0200)
committerPhilipp Gesang <phg@phi-gamma.net>
Fri, 2 Oct 2015 20:35:19 +0000 (22:35 +0200)
When traversing the directory tree, cargo will omit paths that start
with a period character to avoid interfering with other software.
Unfortunately this also prevents a crate from being located in a
directory prefixed with a period. Address this by extending the test
against the traversal root that already guards Git submodules.

Fixes issue #1999 which was introduced with commit 11144645f..

src/cargo/ops/cargo_read_manifest.rs

index 741445510b9447693c0727aa1944615f053f1186..319bf80f210c015d0d75657cd20e246f385eb249 100644 (file)
@@ -43,15 +43,17 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
     try!(walk(path, &mut |dir| {
         trace!("looking for child package: {}", dir.display());
 
-        // Don't recurse into hidden/dot directories
-        let name = dir.file_name().and_then(|s| s.to_str());
-        if name.map(|s| s.starts_with(".")) == Some(true) {
-            return Ok(false)
-        }
-
-        // Don't automatically discover packages across git submodules
-        if dir != path && fs::metadata(&dir.join(".git")).is_ok() {
-            return Ok(false)
+        // Don't recurse into hidden/dot directories unless we're at the toplevel
+        if dir != path {
+            let name = dir.file_name().and_then(|s| s.to_str());
+            if name.map(|s| s.starts_with(".")) == Some(true) {
+                return Ok(false)
+            }
+
+            // Don't automatically discover packages across git submodules
+            if fs::metadata(&dir.join(".git")).is_ok() {
+                return Ok(false)
+            }
         }
 
         // Don't ever look at target directories